package com.platform.module.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.core.text.Convert;
import com.platform.common.utils.DateUtils;
import com.platform.module.domain.MeterRead;
import com.platform.module.mapper.MeterReadMapper;
import com.platform.module.mapper.MeterReadMapper;
import com.platform.module.service.IMeterReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * 热数据记录Service业务层处理
 * 
 * @author wangqi
 * @date 2020-08-04
 */
@Service
public class MeterReadServiceImpl extends ServiceImpl<MeterReadMapper,MeterRead> implements IMeterReadService
{
    @Autowired
    private MeterReadMapper meterReadMapper;

    /**
     * 查询热数据记录列表
     * 
     * @param meterRead 热数据记录
     * @return 热数据记录
     */
    @Override
    public List<MeterRead> selectMeterReadList(MeterRead meterRead)
    {
        return meterReadMapper.selectMeterReadList(meterRead);
    }

    /**
     * 新增热数据记录
     * 
     * @param meterRead 热数据记录
     * @return 结果
     */
    @Override
    @Transactional
    public int insertMeterRead(MeterRead meterRead)
    {
        meterRead.setCreateTime(DateUtils.getNowDate());
        return meterReadMapper.insert(meterRead);
    }

    /**
     * 修改热数据记录
     * 
     * @param meterRead 热数据记录
     * @return 结果
     */
    @Override
    @Transactional
    public int updateMeterRead(MeterRead meterRead)
    {
        return meterReadMapper.updateById(meterRead);
    }

    /**
     * 删除热数据记录对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteMeterReadByIds(String ids)
    {
        return meterReadMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除热数据记录信息
     * 
     * @param id 热数据记录ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteMeterReadById(Long id)
    {
        return meterReadMapper.deleteById(id);
    }
}
